<%-- 
/*
Assignment 1
Class ID        : SE0691
Group           : 1
Due Date        : 20 November 2012
I declare that this assignment is my own work
in accordance with FPT Policy.
*/
--%>

<%@page import="edu.fpt.hib.Users"%>
<%@page import="edu.fpt.hib.Apartment"%>
<%@page import="edu.fpt.dal.ApartmentDAL"%>
<%@page import="edu.fpt.hib.ApartmentEntity"%>
<%@page import="edu.fpt.hib.UserEntity"%>
<%@page import="edu.fpt.dal.UsersDAL"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Detail of user</title>
        <style type="text/css"> <!--@import url("../style.css");--></style>
        <script>function goBack()  {  window.history.back()  }</script>
    </head>
    <body>

        <%@include file="template/header.jsp" %>

        <div id="page">

            <%
                if (UsersDAL.getUsersHQL(request.getParameter("userid")) == null) {
            %>
            User not found!
            <input class="searchsubmit" type='button' value='Back' onclick='goBack()'>
            <% } else {
                //Users user = UsersDAL.getUsersHQL(request.getParameter("userid"));
                Users user = UsersDAL.getUsersHQL(request.getParameter("userid"));
                Apartment apart = ApartmentDAL.getApartmentByUserHQL(user.getUserId());
            %>
            <h2 class="title">Details of : <%=user.getUserFullName()%></h2>
            <table border="0">
                <tr>
                    <td>User ID</td>
                    <td><%=user.getUserId() %></td>
                </tr>
                <tr>
                    <td>Full Name</td>
                    <td><%=user.getUserFullName()%></td>
                </tr>
                <tr>
                    <td>Created Date</td>
                    <td><%=user.getUserCreateDate()%></td>
                </tr>
                <tr>
                    <td>User Role</td>
                        <td><% int role = user.getUserRole();
                        if (role == 1) {%> Administrator
                        <%} else {%>
                        Normal User
                        <%}
                        %></td>
                </tr>
                <% if (apart != null) {
                %>
                <tr>
                    <td>Using Apartment</td>
                    <td><%=apart.getApartId()%></td>
                </tr>
                <tr>
                    <td>Ownership</td>
                    <td><% if (apart.getIsOwn()) {%> Owner
                        <%} else {%>
                        Tenant
                        <%}
                        %></td>
                </tr>
                <tr>
                    <td>Billing Status</td>
                    <td><% if (apart.getBillStatus()) {%> Paid
                        <%} else {%>
                        Not Paid
                        <%}
                        %></td>
                </tr>
                <%}
                    }

                %>
            </table>
            <input class="searchsubmit" type='button' value='Back' onclick='goBack()'>
        </div>
        <%@include file="template/footer.jsp" %>
    </body>
</html>
